home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_sol_transformer.cog < prev    next >
Text File  |  1999-11-15  |  9KB  |  285 lines

  1. # Jones 3D Cog Script
  2. #
  3. # SOL_Transformer.cog
  4. #
  5. # [TRM] && [MDR]
  6. #
  7. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  8. # ========================================================================================
  9.  
  10. symbols
  11.  
  12.     message     user0
  13.     message     entered
  14.     message     pulse
  15.     
  16.     thing       player          local
  17.     thing       tVictim         local
  18.     thing       deadIndy        local
  19.     thing       zapStart
  20.     thing       lampStart
  21.     thing       trackStart
  22.     
  23.     thing       ghostZap
  24.     thing       ghostLamp
  25.     thing       ghostTrack
  26.     
  27.     sector      powerOff
  28.     sector      powerOn
  29.     
  30.     sound       sfx_Shock=sol_trnsfrmr_zapb.wav     local       # long zap
  31.     sound       humm=sol_trnsfrmr_zap.wav           local       # short zap
  32.     sound       say_ow=inxj017g.wav                 local       # ow!
  33.     sound       say_Ugh=inxj018a.wav                local       # dead voice
  34.     
  35.     keyframe    inShocked=in_hit_shocked.key    local
  36.     keyframe    mc_shock_die=im_die.key         local
  37.     keyframe    mc_shock=im_hithead.key         local
  38.     keyframe    inDie=in_die_buckle.key         local
  39.     
  40.     template    tpl_Indy=indy_sh_actor          local
  41.     
  42.     vector      zapTarg         local
  43.     vector      lampTarg        local
  44.     vector      trackTarg       local
  45.     
  46.     int         zap             local
  47.     int         playing=0       local
  48.     int         randNum         local
  49.     int         zzzt            local
  50.     int         blownUp=0       local
  51.     
  52. end
  53.  
  54. # ========================================================================================
  55.  
  56. code
  57.  
  58. user0:
  59.  
  60.     blownUp = 1;
  61.     return;
  62.     
  63. # ========================================================================================
  64.  
  65. entered:
  66.     
  67.     if(GetSenderRef() == powerOn)
  68.     {
  69.         # Start the zapper
  70.         SetPulse(0.5);
  71.     }
  72.         
  73.     else if(GetSenderRef() == powerOff)
  74.     {
  75.         # Kill the zapper
  76.         SetPulse(0.0);
  77.     }   
  78.         
  79.     return;
  80.  
  81. # ========================================================================================
  82.  
  83. pulse:
  84.     
  85.     player = GetLocalPlayerThing();
  86.     zapTarg = GetThingPOS(ghostZap);
  87.     lampTarg = GetThingPOS(ghostLamp);
  88.     trackTarg = GetThingPOS(ghostTrack);
  89.     
  90.     # easy difficutly
  91.     if(GetDifficulty() > 3)
  92.     {
  93.         randNum = RandBetween(1, 5);
  94.     }
  95.     
  96.     # medium difficulty
  97.     else if(GetDifficulty() == 3)
  98.     {
  99.         randNum = RandBetween(1, 2);
  100.     }
  101.     
  102.     # hard difficulty
  103.     else
  104.     {
  105.         randNum = 1;
  106.     }
  107.     
  108.     if((playing == 1) || (randNum > 1))
  109.     {
  110.         return;
  111.     }
  112.     
  113.     else if((blownUp == 0) && (randNum == 1))
  114.     {
  115.         playing = 1;
  116.         zzzt = PlaySoundThing(humm, zapStart, 1.0, 10.0, 20.0, 0);
  117.         CreateLightning(zapStart, '0 0 0', zapTarg, 0.005, 0.005, 0.5);   # 0.03
  118.         
  119.         Sleep(0.5);
  120.         #StopSound(zzzt, 0.2);
  121.         zzzt = PlaySoundThing(humm, zapStart, 1.0, 10.0, 20.0, 0);
  122.         CreateLightning(zapStart, '0 0 0', zapTarg, 0.005, 0.005, 0.1);
  123.         
  124.         Sleep(0.2);
  125.         #StopSound(zzzt, 0.2);
  126.         zzzt = PlaySoundThing(humm, zapStart, 1.0, 10.0, 20.0, 0);
  127.         CreateLightning(zapStart, '0 0 0', zapTarg, 0.005, 0.005, 0.3);
  128.         
  129.         Sleep(0.5);
  130.         #StopSound(zzzt, 0.2);
  131.         zzzt = PlaySoundThing(humm, zapStart, 1.0, 10.0, 20.0, 0);
  132.         CreateLightning(zapStart, '0 0 0', zapTarg, 0.005, 0.005, 0.1);
  133.         
  134.         Sleep(0.1);
  135.         #StopSound(zzzt, 0.2);
  136.         playing = 0;
  137.     }
  138.     
  139.     else if((blownUp == 1) && (randNum == 1))
  140.     {
  141.         playing = 1;
  142.         zzzt = PlaySoundThing(humm, ghostZap, 1.0, 10.0, 20.0, 0);
  143.         CreateLightning(zapStart, '0 0 0', zapTarg, 0.03, 0.03, 0.5);
  144.         
  145.         Sleep(0.2);
  146.         #StopSound(zzzt, 0.2);
  147.         
  148.         zzzt = PlaySoundThing(humm, ghostLamp, 1.0, 10.0, 20.0, 0);
  149.         CreateLightning(lampStart, '0 0 0', lampTarg, 0.03, 0.03, 0.5);
  150.         
  151.         Sleep(0.2);
  152.         #StopSound(zzzt, 0.2);
  153.         zzzt = PlaySoundThing(humm, ghostTrack, 1.0, 10.0, 20.0, 0);
  154.  
  155.         # Is there anybody we can zap?
  156.         zap        = 0;
  157.         tVictim = FirstThingInSector(GetThingSector(ghostTrack));
  158.         
  159.         while ( tVictim != -1 && zap == 0 )
  160.         {
  161.             # zap player if close enough to trackTarg
  162.             if ( GetThingType(tVictim) == 10 )    # victim is the player
  163.             {
  164.                 if (VectorDist(GetThingPos(player), trackTarg) < 0.15)   # 1.5m
  165.                 {
  166.                     zap    = 1;    # record a lightening strike
  167.  
  168.                     # player is in minecar
  169.                     if(BitTest(GetPhysicsFlags(player), 0x01000000))
  170.                     {
  171.                         # player is ducking, don't damage him
  172.                         if((GetMoveStatus(player) >= 51) && (GetMoveStatus(player) <= 53))
  173.                         {
  174.                             # just hit default target
  175.                             CreateLightning(trackStart, '0 0 0', trackTarg, 0.03, 0.03, 0.5);
  176.                         }
  177.                         
  178.                         # player is not ducking, fry him!
  179.                         else
  180.                         {
  181.                             StopSound(zzzt, 0.2);
  182.                             PlaySoundThing(sfx_Shock, ghostTrack, 1.0, 10.0, 20.0, 0);
  183.                             
  184.                             CreateLightning(trackStart, '0 0 0', VectorAdd(GetThingPos(player), '0.0 0.0 0.05'), 0.03, 0.03, 0.5);
  185.                             
  186.                             # shock mine car player
  187.                             PlaySoundLocal(say_ow, 1.0, 0.0, 0x0, 0);
  188.                             PlayKey(player, mc_shock, 4, 0x12, 1);
  189.                             DamageThing(player, 100.0, 0x1, player);
  190.                             
  191.                             # player is dead, say so!
  192.                             if(GetThingHealth(player) <= 0)
  193.                             {
  194.                                 PlaySoundLocal(say_Ugh, 1.0, 0.0, 0x0, 0);
  195.                             }
  196.                         }
  197.                     }
  198.             
  199.                     # player is on foot
  200.                     else
  201.                     {
  202.                         StopSound(zzzt, 0.2);
  203.                         PlaySoundThing(sfx_Shock, ghostTrack, 1.0, 10.0, 20.0, 0);
  204.                             
  205.                         CreateLightning(trackStart, '0 0 0', VectorAdd(GetThingPos(player), '0.0 0.0 0.05'), 0.03, 0.03, 0.5);
  206.                 
  207.                         # player is dying or already dead
  208.                         if(BitTest(GetThingFlags(player), 0x202))
  209.                         {
  210.                             return;
  211.                         }
  212.                         
  213.                         # disable controls and make sure player is stopped before playing key
  214.                         SetActorFlags(player, 0x200000);
  215.                         StopThing(player);
  216.                         PlayMode(player, 1, 0);
  217.                 
  218.                         # damage player
  219.                         DamageThing(player, 100.0, 0x1, player);
  220.                         
  221.                         if((GetMoveStatus(player) != 3) && (GetMoveStatus(player) != 4) && (GetMoveStatus(player) != 5) && (GetMoveStatus(player) != 64) && (GetMoveStatus(player) != 65))
  222.                         {
  223.                             if(GetThingHealth(player) > 0)
  224.                             {
  225.                                 PlayKey(player, inShocked, 4, 0x12, 1);
  226.                             }
  227.                         }
  228.                         
  229.                         # restore player control
  230.                         ClearActorFlags(player, 0x200000);
  231.                         
  232.                         # player is dead
  233.                         if(GetThingHealth(player) <= 0)
  234.                         {
  235.                             PlaySoundLocal(say_Ugh, 1.0, 0.0, 0x0, 0);
  236.                             
  237.                             # hide player
  238.                             SetThingFlags(player, 0x80000);
  239.                             
  240.                             deadIndy = CreateThing(tpl_Indy, player);
  241.                             CaptureThing(deadIndy);
  242.                             
  243.                             # Show actor Indy and play Keyframe
  244.                             ClearThingFlags(deadIndy, 0x80000);
  245.                             PlayKey(deadIndy, inDie, 4, 0x14, 0);
  246.                         }
  247.                     }
  248.                 }
  249.             }
  250.             
  251.             # zap actors who are close enough to trackTarg
  252.             else if ( GetThingType(tVictim) == 2 )    # victim is an actor
  253.             {
  254.                 if (VectorDist(GetThingPos(tVictim), trackTarg) < 0.15)   # 1.5m
  255.                 {
  256.                     StopSound(zzzt, 0.2);
  257.                     PlaySoundThing(sfx_Shock, ghostTrack, 1.0, 10.0, 20.0, 0);
  258.                             
  259.                     zap    = 1;    # record a lightening strike
  260.                     CreateLightning(trackStart, '0 0 0', VectorAdd(GetThingPos(tVictim), '0.0 0.0 0.05'), 0.03, 0.03, 0.5);
  261.                     DamageThing(tVictim, 100.0, 0x1, tVictim);
  262.                 }
  263.             }
  264.         
  265.             tVictim = NextThingInSector(tVictim);
  266.         }
  267.  
  268.         # No victims, just hit default target
  269.         if ( zap == 0 )
  270.         {
  271.             CreateLightning(trackStart, '0 0 0', trackTarg, 0.03, 0.03, 0.5);
  272.         }
  273.  
  274.         Sleep(0.1);
  275.         #StopSound(zzzt, 0.2);
  276.         playing = 0;
  277.     }
  278.     
  279.     return;
  280.  
  281. # ========================================================================================
  282.  
  283. end
  284.  
  285.